Repository navigation
build: make an unused using a build error (IDE0005) - #1199
Conversation
Removes the 176 unused using directives that IDE0005 reports once the compiler produces documentation, and fixes the five XML doc warnings it also surfaces in Domain: three crefs left stale when DiscountReasonCode moved to Contracts or that point into Application, and two missing param tags on CeilingBreach.
IDE0005 reports during a build only when the compiler produces documentation (dotnet/roslyn#41640), so a planted unused using passed the build and dotnet format on #858. GenerateDocumentationFile is now on for every project, with CS1591 off, and IDE0005 is a warning, which TreatWarningsAsErrors turns into an error. Migrations are exempt: the scaffold writes using System; and InitialCreate is frozen (#407). Closes #1187
…nforced-rules table
|
Review round 1 (Codex, read-only) at Build gate: works. A temporary unused Finding 1 (doc): the Enforced rules table promises more than the checks enforce. Rows to narrow (
Smallest fix: state each check's real trigger and exemptions, and leave the checks as they are. Note for the body, not a defect: publish output now includes four XML doc files (about 64 KB), and the Development-only OpenAPI document picks up the XML comments. VERDICT: 0 product defects, 1 doc finding. |
|
Reply to review round 1. The head is now Finding 1 (the table promised more than the checks enforce). Fixed in
The intro says a row can be narrower than the prose rule it backs, and that frozen hits stop new cases only. Output notes. The PR body now names the four published XML files (about 64 KB, from the SDK's publish defaults). It also notes that Checks on |
Closes #1187
AGENTS.md said an unused
usingbreaks the build. It did not: on #858 a planted unusedusingpassed bothdotnet buildanddotnet format, so reviewers have been checking by hand. This PR makes the rule true.What changes.
Directory.Build.propssetsGenerateDocumentationFilefor every project, with CS1591 (missing XML comment) off. IDE0005 reports during a build only when the compiler produces documentation (dotnet/roslyn#41640)..editorconfigsets IDE0005 towarning, whichTreatWarningsAsErrorsturns into an error.Cluckwork.Api.csprojdrops its ownGenerateDocumentationFile=false. That line came from the first scaffold (Scaffold .NET solution #1), and its comment ("Expose Program for WebApplicationFactory") describes something else. Without this change, Api would be the one project the gate skips. With documentation on, the OpenAPI document picks up XML comments, butMapOpenApiis mapped only in Development.dotnet ef migrations addwritesusing System;, which ImplicitUsings makes unused, andInitialCreateis frozen (feat(eggs): make cracked and dirty eggs sellable stock via condition grades (#396) #407).Commits.
bce9273cremoves the 208 unused using directives the gate reports, across 181 files, usingdotnet format style --diagnostics IDE0005. That is 176 diagnostics, since one diagnostic can cover adjacent lines; the commit message says "176 unused using directives", which counts diagnostics. By project: Application 146, IntegrationTests 152, Infrastructure 36, Domain 12 and Application.Tests 6 diagnostic lines (the build log prints each one twice). It also fixes the five XML doc warnings documentation generation surfaced in Domain. Three crefs had gone stale: two afterDiscountReasonCodemoved toContracts, and one pointing into Application, which Domain cannot reference. Twoparamtags were missing onCeilingBreach. Usings only change what names resolve; the solution builds and the tests below pass.54c1ba74turns on the gate.59db4585updates the docs, and review round 1 narrowed the table in a later commit.src/AGENTS.mdand.editorconfignow state what is enforced, and the build: enforce file-scoped namespaces and using placement at build time #985 paragraph counts three gated rules.AGENTS.mdgains the Enforced rules table (rule, enforcer, where it runs) for this program's checks: test: cap tracked source files at 500 lines #1153, chore(web): add ESLint with react-hooks rules and bulk suppressions #1155, chore: block forbidden agent git commands with a PreToolUse hook #1158/chore: add git hooks that refuse commits on main and unsafe pushes #1172/chore: run the agent git guard in Pi and Hermes #1175, test(arch): ratchet test types that parse C# without binding symbols #1189, chore(web): add useLatestLoad and lint raw async effects #1190, test(web): require an in-app glossary entry or a reasoned exclusion for every GLOSSARY.md term #1193, ci: flag user-facing strings and glossary changes that ship without their docs #1194 and this PR.Merge order. The #1189 and #1193 rows name tests that land with those PRs, which are still open.
Tests run locally:
dotnet build Cluckwork.slnx --no-incremental(0 warnings, 0 errors), Domain.Tests (496 passed), Application.Tests (766 passed), and the two IntegrationTestsImagePinguards.Proof.
077f27e7, 2026-10-09) addedusing Cluckwork.Infrastructure.Persistence;andusing Microsoft.AspNetCore.Mvc.Testing;toOAuthFailClosedTests.ConnectedAppsSwitch.cs, and neither was ever used. This PR removes them. Putting both back on the branch head failsdotnet build Cluckwork.slnx:tests/Cluckwork.Api.IntegrationTests/OAuthFailClosedTests.ConnectedAppsSwitch.cs(8,1): error IDE0005: Using directive is unnecessary.using System.Text.RegularExpressions;inIdempotencyMiddleware.csfails the build:src/Cluckwork.Api/Middleware/IdempotencyMiddleware.cs(1,1): error IDE0005: Using directive is unnecessary.Build time. No measurable change. Four alternating
dotnet build Cluckwork.slnx --no-incrementalruns on this shared host (load 12–16) took 27.6 s and 27.6 s on the branch, against 29.3 s and 26.3 s onmainat734a8343.Output changes.
dotnet publishnow ships four XML documentation files with the image:Cluckwork.Api.xml,Cluckwork.Application.xml,Cluckwork.Domain.xmlandCluckwork.Infrastructure.xml, about 64 KB in total. The SDK setsPublishDocumentationFileandPublishReferencesDocumentationFilesby default.AddOpenApi()reads these XML comments into the OpenAPI document, which .NET 10 does by default. The document is served only in Development (MapOpenApi()inProgram.cs), so production responses do not change.